package kubayaxi.video.client.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import kubayaxi.video.client.service.ISearchService;
import kubayaxi.video.mybatis.auto.model.Channel;
import kubayaxi.video.mybatis.customize.model.search.dto.SearchChannelDTO;
import kubayaxi.video.mybatis.customize.model.search.dto.SearchUserDTO;
import kubayaxi.video.mybatis.customize.model.search.dto.SearchVideoDTO;
import kubayaxi.video.mybatis.customize.model.search.vo.SearchUserVO;
import kubayaxi.video.mybatis.customize.model.search.vo.SearchVideoVO;
import kubayaxi.video.service.base.common.request.BaseRequest;
import kubayaxi.video.service.base.common.response.ResponseResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/client/search")
@Api(tags = "搜索")
public class SearchController {

    @Resource
    private ISearchService searchService;

    @ApiOperation("视频搜索")
    @PostMapping("/video")
    public ResponseResult<List<SearchVideoVO>> video(@RequestBody BaseRequest<SearchVideoDTO> dto){
        List<SearchVideoVO> ans = searchService.video(dto);
        return ResponseResult.success(ans);
    }

    @ApiOperation("用户搜索")
    @PostMapping("/user")
    public ResponseResult<List<SearchUserVO>> user(@RequestBody BaseRequest<SearchUserDTO> dto){
        List<SearchUserVO> ans = searchService.user(dto);
        return ResponseResult.success(ans);
    }

    @ApiOperation("频道搜索")
    @PostMapping("/channel")
    public ResponseResult<List<Channel>> channel(@RequestBody BaseRequest<SearchChannelDTO> dto){
        List<Channel> ans = searchService.channel(dto);
        return ResponseResult.success(ans);
    }
}
